﻿package mortal.game.view.copy.groupCopy.view
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import flash.text.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class GroupCopyName extends GSprite
    {
        private var _leftSide:GBitmap;
        private var _rightSide:GBitmap;
        private var _name:GTextFiled;
        private var _nameBitmap:GImageBitmap;

        public function GroupCopyName()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._leftSide = UIFactory.gBitmap("", 0, 13, this);
            this._rightSide = UIFactory.gBitmap("", 0, 13, this);
            this._nameBitmap = UIFactory.gImageBitmap("", 0, 0, this, null);
            var _loc_1:* = GlobalStyle.textFormatChen;
            _loc_1.size = 20;
            this._name = UIFactory.gTextField("", 0, 0, 100, 20, this, _loc_1);
            this._name.autoSize = TextFieldAutoSize.CENTER;
            var _loc_2:* = GlobalClass.getBitmapData(ImagesConst.GroupCopySide);
            this._rightSide.bitmapData = GlobalClass.getBitmapData(ImagesConst.GroupCopySide);
            this._leftSide.bitmapData = _loc_2;
            this._rightSide.scaleX = -1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._leftSide.dispose(param1);
            this._leftSide = null;
            this._rightSide.dispose(param1);
            this._rightSide = null;
            this._name.dispose(param1);
            this._name = null;
            this._nameBitmap.dispose(param1);
            this._nameBitmap = null;
            return;
        }// end function

        public function set copyName(param1:String) : void
        {
            this._name.text = param1;
            this.resetPosition();
            return;
        }// end function

        public function set copyUrl(param1:String) : void
        {
            this._nameBitmap.imgUrl = param1;
            this._nameBitmap.onLoadCompl = this.resetPosition;
            this.resetPosition();
            return;
        }// end function

        private function resetPosition() : void
        {
            if (isDisposed)
            {
                return;
            }
            if (this._name.text)
            {
                this._name.x = (-this._name.width) / 2;
                this._leftSide.x = this._name.x - this._leftSide.width - 3;
                this._rightSide.x = this._name.width / 2 + this._rightSide.width;
                var _loc_1:* = this._name.textHeight >> 1;
                this._rightSide.y = this._name.textHeight >> 1;
                this._leftSide.y = _loc_1;
            }
            else
            {
                this._nameBitmap.x = (-this._nameBitmap.width) / 2;
                this._leftSide.x = this._nameBitmap.x - this._leftSide.width - 15;
                this._rightSide.x = this._nameBitmap.width / 2 + this._rightSide.width + 15;
                var _loc_1:* = (this._nameBitmap.height >> 1) - 5;
                this._rightSide.y = (this._nameBitmap.height >> 1) - 5;
                this._leftSide.y = _loc_1;
            }
            return;
        }// end function

    }
}
